﻿using System.Windows;
using System.Windows.Controls;

namespace OptoMeasure.Extension;

public static class WindowOpenHelper
{
    private static readonly int MaxWidth = 1200;
    private static readonly int MaxHeigth = 800;

    public static void ShowDialog(this UserControl content, string title = "")
    {
        var window = new Window();
        window.Icon = Application.Current.MainWindow.Icon;
        window.Title = title;
        window.Width = Math.Min(content.Width + 40, MaxWidth);
        window.Height = Math.Min(content.Height + 10, MaxHeigth);
        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        window.Owner = Application.Current.MainWindow;
        window.Content = content;
        window.ShowDialog();
    }
}